package com.wuyan.locationdog.view

import android.content.Context
import android.graphics.Color
import android.graphics.Typeface
import android.view.Gravity
import android.view.View
import android.view.animation.Animation
import android.widget.ImageView
import android.widget.TextView
import com.amap.api.maps.AMap
import com.arcsoft.commonbase.databinding.DialogAgreePrivacyBinding
import com.arcsoft.commonbase.ext.gone
import com.arcsoft.commonbase.ext.invisible
import com.arcsoft.commonbase.ext.visible
import com.bigkoo.pickerview.adapter.ArrayWheelAdapter
import com.blankj.utilcode.util.ColorUtils
import com.contrarywind.view.WheelView
import com.wuyan.locationdog.R
import com.wuyan.locationdog.databinding.LoginActivityBinding
import com.wuyan.locationdog.databinding.PopMapSelectBinding
import com.wuyan.locationdog.databinding.PopTimeSelectBinding
import leifu.shapelibrary.ShapeView
import razerdp.basepopup.BasePopupWindow
import razerdp.util.animation.AnimationHelper
import razerdp.util.animation.TranslationConfig


class MapSelectPopup(context: Context?, var mapType: Int, var sureCallback: ((Int) -> Unit)? = null) : BasePopupWindow(context) {


    var mBinding: PopMapSelectBinding? = null

    init {
        contentView = createPopupById(R.layout.pop_map_select)
        popupGravity = Gravity.BOTTOM
    }

    override fun onViewCreated(contentView: View) {
        super.onViewCreated(contentView)
        mBinding = PopMapSelectBinding.bind(contentView)

        mBinding?.apply {
            if (mapType == AMap.MAP_TYPE_SATELLITE) {
                shapeView.setShapeStrokeColor(ColorUtils.getColor(com.arcsoft.commonbase.R.color.white))
                    .setShapeSolidColor(Color.WHITE)
                    .setUseShape()
                ivSelect.gone()

                shapeView2.setShapeStrokeColor(ColorUtils.getColor(com.arcsoft.commonbase.R.color.text_color_selected))
                    .setShapeSolidColor(Color.WHITE)
                    .setUseShape()
                ivSelect2.visible()
            }
            btnStander.setOnClickListener {
                sureCallback?.invoke(AMap.MAP_TYPE_NORMAL)
                dismiss()
            }
            shapeView.setOnClickListener {
                btnStander.callOnClick()
            }
            shapeView2.setOnClickListener {
                btnWeiXing.callOnClick()
            }
            btnWeiXing.setOnClickListener {
                sureCallback?.invoke(AMap.MAP_TYPE_SATELLITE)
                dismiss()
            }


            btnClose.setOnClickListener {
                dismiss()
            }


        }

    }

    /**
     * 粗体 布局 下划线等切换ui
     */
    private fun PopTimeSelectBinding.tabResetUi() {

        tab1Line.invisible()
        tab2Line.invisible()
        tab3Line.invisible()

        tab1.setTextSize(14F)
        tab2.setTextSize(14F)
        tab3.setTextSize(14F)

        tab1.setTextColor(Color.parseColor("#969799"))
        tab2.setTextColor(Color.parseColor("#969799"))
        tab3.setTextColor(Color.parseColor("#969799"))

    }

    override fun onCreateShowAnimation(): Animation? {
        return AnimationHelper.asAnimation()
            .withTranslation(TranslationConfig.FROM_BOTTOM)
            .toShow()
    }

}
